home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # sdr.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: sdr.cgi,v 1.18 1997/06/19 22:26:39 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
-
- use POSIX;
-
- $myname = "sdr.cgi";
- $list_script = "Apps.sdpd.cgi";
-
- $file_dir = "$document_root/apps/sdpd-send";
-
- $exp_date = "12-Dec-98";
-
- @months = ('Jan','Feb','Mar','Apr','May','Jun',
- 'Jul','Aug','Sep','Oct','Nov','Dec');
- @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
-
- if ($ARGV[0]) {
- $edit_file = $ARGV[0];
- $fld{'mode'} = "e";
- } else { $fld{'mode'} = "a"; }
-
- &get_cookies;
- &get_fields;
-
- if ($fld{'get_id'}) { # being called via "post" from sd-list.cgi
- $new_id = time;
-
- $fld{'sdpd_email'} = $fld{'sdpd_email'};
- if($fld{'sdpd_name'} ne "") {
- $fld{'sdpd_email'} .= " ($fld{'sdpd_name'})";
- }
- $fld{'sdpd_phone'} = $fld{'sdpd_phone'};
-
- $cookie_header = "Content-type: text/html\n"
- . "Set-Cookie: sdpd_id=$new_id; expires=$exp_date; path=/\n"
- . "Set-Cookie: sdpd_phone=$fld{'sdpd_phone'}; expires=$exp_date; path=/\n"
- . "Set-Cookie: sdpd_email=$fld{'sdpd_email'}; expires=$exp_date; path=/\n\n";
-
- $set_cookie = 1;
- }
-
- &set_timezone;
-
- if ($edit_file) { &get_edit_values; }
- else { &get_initial_values; }
-
- if ($fld{'submit'} eq 'Submit Announcement') {
- $fld{'session_name'} =~ s/^\s+//g;
- $fld{'session_name'} =~ s/\s+$//g;
- if (!&form_validation) {
- &create_file;
- $fld{'session_name'} =~ s/ /__/g;
- $list_script .= "?$fld{'mode'}+$fld{'session_name'}";
-
- print "Content-type: text/html\n$update_cookie\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$list_script\">";
- print "</HEAD><BODY></BODY></HTML>";
-
- exit 0;
- }
- %val = %fld;
- }
-
- &generic;
-
- sub get_cookies {
- local($a, $b);
- undef %cookie;
- foreach (split(/; /, $ENV{HTTP_COOKIE})) {
- ($a, $b) = split(/=/, $_);
- $a =~ s/\s//g;
- $cookie{$a} = $b;
- }
- }
-
- sub form_validation {
- if ($fld{'session_name'} eq "") {
- $error = "Session name required.";
- return 1;
- } elsif ($fld{'address'} eq "") {
- $error = "Address required.";
- return 1;
- } elsif (check_ipaddr($fld{'address'})) {
- $error = "Invalid IP address in \"Address\" field.";
- return 1;
- }
-
- if ($fld{'audio_check'}) {
- if (($error = &check_port($fld{'audio_port'})) ne "") { return 1; }
- } elsif ($fld{'video_check'}) {
- if (($error = &check_port($fld{'video_port'})) ne "") { return 1; }
- } elsif ($fld{'white_check'}) {
- if (($error = &check_port($fld{'white_port'})) ne "") { return 1; }
- } elsif ($fld{'text_check'}) {
- if (($error = &check_port($fld{'text_port'})) ne "") { return 1; }
- }
-
- if ($fld{'email'} eq "") {
- $error = "E-mail address required.";
- return 1;
- } elsif ($fld{'phone'} eq "") {
- $error = "Telephone number required.";
- return 1;
- }
- }
-
- sub check_port {
- if ($_[0] =~ /[^\d]/) { return "Port numbers must be integers."; }
- elsif ($_[0] < 1024) { return "Port numbers must be more than 1023."; }
- elsif ($_[0] > 65536) { return "Port numbers must be less tnan 65536."; }
- "";
- }
-
- sub create_file {
-
- if ($edit_file ne "") { $file = $edit_file; }
- elsif ($fld{'edit_file'} ne "") { $file = $fld{'edit_file'}; }
- else {
- $file = tmpnam(0);
- $file =~ /\/([^\/]*)$/;
- $file = $file_dir . "/" . $1;
- }
-
- foreach (keys(%months)) {
- if ($months{$_} eq $cur_month) { $cur_month_num = $_; }
- }
-
- ($s_hour, $s_min) = split(/:/,$fld{'time'});
- ($s_wday_nm, $s_mon_nm, $s_mday) = split(/\s+/,$fld{'date'});
-
- for ($i=0;$i<=$#months;$i++) {
- if ($months[$i] eq $s_mon_nm) { $s_mon = $i; }
- }
-
- if ($month_num < $cur_month_num) { $s_year = $c_year + 1; }
- else { $s_year = $c_year; }
-
- $start_time = mktime(0,$s_min,$s_hour,$s_mday,$s_mon,$s_year,0,0,-1);
- $start_time += 2208988800;
-
- if ($fld{'duration'} =~ /minutes/) { $dur_secs = 30 * 60; }
- elsif ($fld{'duration'} =~ /(\d+) hour/) { $dur_secs = 3600 * $1; }
- else { $dur_secs = 24 * 3600; }
-
- $rep_secs = 0;
- if ($fld{'active'} ne "once") {
- if ($fld{'repeat'} =~ /(\d+) hour/) { $rep_secs = 3600 * $1; }
- elsif ($fld{'repeat'} =~ /(\d+) day/) { $rep_secs = 24 * 3600 * $1; }
- else { $fld{'repeat'} =~ /(\d+) week/; $rep_secs = 7 * 24 * 3600 * $1; }
-
- if ($fld{'active'} eq 'daily') { $repeat_time = 24 * 3600; }
- else { $repeat_time = 7 * 24 * 3600; }
- }
-
- $finish_time = $start_time + $dur_secs + $rep_secs;
-
- %ttl = ('site','15','region','63','world','127');
-
- if ($new_id) { $file_id = $new_id; }
- else { $file_id = $cookie{'sdpd_id'}; }
-
- open(OUT,"> $file");
-
- print OUT qq|# $file_id\n#\n|;
-
- print OUT qq|vers2\n|;
- print OUT qq|v=0\n|;
-
- if ($fld{'mode'} eq "a") {
- open(IN, "/usr/bin/whoami |");
- $fld{'username'} = <IN>; chop($fld{'username'});
- close(IN);
- $fld{'session_id'} = time + 2208988800;
- $fld{'version'} = $fld{'session_id'};
-
- open(IN, "/usr/OnRamp/bin/htnetwork |");
- $my_line = <IN>;
- close(IN);
- $fld{'my_ip'} = (split(/:/,$my_line))[3];
-
- # @addrs = (gethostbyname($ENV{SERVER_NAME}))[4];
- # $fld{'my_ip'} = join('.',unpack('C4', $addrs[0]));
- }
-
- print OUT qq|o=$fld{'username'} $fld{'session_id'} $fld{'version'} IN IP4 $fld{'my_ip'}\n|;
-
- print OUT qq|s=$fld{'session_name'}\n|;
-
- $fld{'description'} =~ s/\r\n/ /g;
- print OUT qq|i=$fld{'description'}\n|;
-
- if ($fld{'uri'}) { print OUT qq|u=$fld{'uri'}\n|; }
-
- print OUT qq|e=$fld{'email'}\n|;
- print OUT qq|p=$fld{'phone'}\n|;
-
- print OUT qq|c=IN IP4 $fld{'address'}/$ttl{$fld{'ttl'}}\n|;
-
- print OUT qq|t=$start_time $finish_time\n|;
-
- if ($fld{'active'} ne "once") {
- print OUT qq|r=$repeat_time $dur_secs 0\n|;
- }
-
- if ($fld{'audio_check'}) {
- print OUT qq|m=audio $fld{'audio_port'} $fld{'audio_protocol'}|,
- qq| $fld{'audio_format'}\n|;
- if ($fld{'audio_recv'}) { print OUT qq|a=recvonly\n|; }
- }
- if ($fld{'video_check'}) {
- print OUT qq|m=video $fld{'video_port'} $fld{'video_protocol'}|,
- qq| $fld{'video_format'}\n|;
- if ($fld{'video_recv'}) { print OUT qq|a=recvonly\n|; }
- }
- if ($fld{'white_check'}) {
- print OUT qq|m=white $fld{'white_port'} $fld{'white_protocol'}|,
- qq| $fld{'white_format'}\n|;
- if ($fld{'white_recv'}) { print OUT qq|a=recvonly\n|; }
- }
- if ($fld{'text_check'}) {
- print OUT qq|m=text $fld{'text_port'} $fld{'text_protocol'}|,
- qq| $fld{'text_format'}\n|;
- if ($fld{'text_recv'}) { print OUT qq|a=recvonly\n|; }
- }
-
- close(OUT);
-
- if ($fld{'email'} ne $cookie{'sdpd_email'}) {
- $update_cookie = "Set-Cookie: sdpd_email=$fld{'email'};"
- . " expires=$exp_date; path=/\n";
- }
- if ($fld{'phone'} ne $cookie{'sdpd_phone'}) {
- $update_cookie .= "Set-Cookie: sdpd_phone=$fld{'phone'};"
- . " expires=$exp_date; path=/\n";
- }
- }
-
- sub get_edit_values {
-
- open(IN, "< $edit_file");
-
- while(<IN>) {
- @items = split(/=/);
- chop($items[1]);
-
- if ($items[0] eq "o") {
-
- ($fld{'username'}, $fld{'session_id'}, $fld{'version'},
- $dum, $dum, $fld{'my_ip'}) = split(/\s+/, $items[1]);
-
- } elsif ($items[0] eq "s") {
-
- $val{'session_name'} = $items[1];
-
- } elsif ($items[0] eq "i") {
-
- @words = split(/\s+/,$items[1]);
-
- $val{'description'} = shift(@words);
- $len = length($val{'description'});
-
- while ($word = shift(@words)) {
- $len += length($word) + 1;
-
- if ($len > 40) {
- $val{'description'} .= "\n$word";
- $len = length($word);
- } else { $val{'description'} .= " $word"; }
- }
-
-
- } elsif ($items[0] eq "u") {
-
- $val{'uri'} = $items[1];
-
- } elsif ($items[0] eq "e") {
-
- $val{'email'} = $items[1];
-
- } elsif ($items[0] eq "p") {
-
- $val{'phone'} = $items[1];
-
- } elsif ($items[0] eq "c") {
-
- ($val{'address'}, $ttl) = split(/\//, (split(/\s+/, $items[1]))[2]);
- if ($ttl == 15) { $val{'ttl'} = "site"; }
- elsif ($ttl == 63) { $val{'ttl'} = "region"; }
- else { $val{'ttl'} = "world"; }
-
- } elsif ($items[0] eq "m") {
-
- ($format, $a, $b, $c) = split(/\s+/, $items[1]);
- $val{$format . "_check"} = "on";
- $val{$format . "_port"} = $a;
- $val{$format . "_protocol"} = $b;
- $val{$format . "_format"} = $c;
-
- } elsif ($items[0] eq "a") {
-
- $val{$format . "_recv"} = "on";
-
- } elsif ($items[0] eq "t") {
-
- ($start, $finish) = split(/\s+/, $items[1]);
- $start -= 2208988800;
- $finish -= 2208988800;
- $time_diff = $finish - $start;
-
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($start);
-
- if ($min == 0) { $min = "00"; }
-
- $val{'date'} = "$days[$wday] $months[$mon] $mday";
- $val{'time'} = $hour . ":" . $min;
-
- } elsif ($items[0] eq "r") {
-
- ($rep_int, $act_dur, $dum) = split(/\s+/, $items[1]);
-
- if ($act_dur < 3600) { $val{'duration'} = "30 minutes"; }
- elsif ($act_dur < 7200) { $val{'duration'} = "1 hour"; }
- elsif ($act_dur < 3600 * 11) {
- $num_hours = $act_dur / 3600;
- $val{'duration'} = "$num_hours hours";
- }
- else { $val{'duration'} = "1 day"; }
-
- if ($rep_int == 3600 * 24) { $val{'active'} = "daily"; }
- else { $val{'active'} = "weekly"; }
-
- }
-
- }
-
- close(IN);
-
- if ($rep_int) {
-
- $repeat = $time_diff - $act_dur;
-
- if ($repeat < 24 * 3600) { $type = "hour"; $num = $repeat / 3600; }
- elsif ($repeat < 7 * 24 * 3600) { $type = "day"; $num = $repeat / (24 * 3600); }
- else { $type = "week"; $num = $repeat / (7 * 24 * 3600); }
-
- if ($num != 1) { $plural = "s"; }
-
- $val{'repeat'} = "$num $type$plural";
-
- } else {
-
- $act_dur = $time_diff;
- if ($act_dur < 3600) { $val{'duration'} = "30 minutes"; }
- elsif ($act_dur < 7200) { $val{'duration'} = "1 hour"; }
- elsif ($act_dur < 3600 * 11) {
- $num_hours = $act_dur / 3600;
- $val{'duration'} = "$num_hours hours";
- }
- else { $val{'duration'} = "1 day"; }
-
- }
-
- $val{'edit_file'} = $edit_file;
- }
-
-
- sub set_timezone {
-
- if (-e "/etc/TIMEZONE") {
- open(IN,"< /etc/TIMEZONE");
- while(<IN>) {
- @items = split(/=/);
- if ($items[0] eq "TZ") {
- chop $items[1];
- $ENV{'TZ'} = $items[1];
- }
- }
- close(IN);
- }
- }
-
- sub get_initial_values {
-
- ($c_sec, $c_min, $c_hour, $c_mday, $c_mon, $c_year, $c_wday, $c_yday,
- $c_isdst) = localtime(time);
-
- $val{'time'} = $c_hour . ":00";
-
- if ($c_mon < 2) { $leap_check = $c_year; }
- else { $leap_check = $c_year + 1; }
-
- $leap_check = 0;
- if ( ($leap_check % 4) == 0 && ($leap_check % 100) != 0 ) { $leap_year = 1; }
- if ($leap_year) { $feb_days = 29; }
- else { $feb_days = 28; }
-
- $val{'date'} = "$days[$c_wday] $months[$c_mon] $c_mday";
-
- srand(time);
-
- $val{'audio_port'} = int(rand(65535-5001)) + 5001;
- $val{'video_port'} = int(rand(65535-5001)) + 5001;
- $val{'white_port'} = int(rand(65535-5001)) + 5001;
- $val{'text_port' } = int(rand(65535-5001)) + 5001;
-
- $ip_3 = int(rand(253)) + 1;
- $ip_4 = int(rand(253)) + 1;
-
- $val{'address'} = "224.2." . $ip_3 . "." . $ip_4;
-
- if ($fld{'get_id'}) {
- $val{'phone'} = $fld{'sdpd_phone'};
- $val{'email'} = $fld{'sdpd_email'};
- } else {
- $val{'phone'} = $cookie{'sdpd_phone'};
- $val{'email'} = $cookie{'sdpd_email'};
- }
-
- $val{'audio_check'} = "on";
- }
-
- sub generic {
-
- if ($set_cookie) { print $cookie_header; }
- else { print qq|Content-type: text/html\n\n|; }
- print qq|<html><head><title>Session Directory Manager</title>\n|;
-
- &print_javascript;
-
- print qq|</head>\n|;
-
- print "<body bgcolor=#CCC28F background=\"/images/sdr-bg.gif\"\n";
- print "link=#27002B vlink=#00582A text=#800019>\n";
-
- print "<table width=100%>\n";
- print "<tr><th align=left><h1>Create Announcement</h1></th>\n";
- print "<th align=right>\n";
- print "<a href=\"/apps/sdr_hlp.cgi\"><img border=0 height=65 width=30 src=\"/images/help.gif\"></a>\n";
- print " ";
- print "<a href=\"/newsplash.shtml\"><img border=0 height=55 width=57 src=\"/apps/home.gif\"></a>\n";
- print " ";
- print "<a href=\"/apps/Apps.shtml\"><img border=0 height=55 width=57 src=\"/apps/back.gif\"></a>\n";
- print "</tr></table>\n";
-
- print qq|<map name="time_map">\n|;
- print qq|<area shape="rect" coords="0,0,15,15" href="JavaScript:TimeUp()">|;
- print qq|<area shape="rect" coords="0,15,15,30" href="JavaScript:TimeDown()">|;
- print qq|</map>|;
-
- print qq|<map name="date_map">\n|;
- print qq|<area shape="rect" coords="0,0,15,15" href="JavaScript:DateUp()">|;
- print qq|<area shape="rect" coords="0,15,15,30" href="JavaScript:DateDown()">|;
- print qq|</map>|;
-
- print qq|<center>\n|;
-
- print qq|</center><i>$message</i><center>\n|;
- if ($error) {print qq|</center><font color=#FF0000>Error: $error</font><center>\n|; }
-
- print qq|<form name="page1" method=post action=$myname>\n|;
-
- print qq|<input type="hidden" name="mode" value=$fld{'mode'}>\n|;
-
- if ($val{'edit_file'}) {
- print qq|<input type="hidden" name="session_id" value=$fld{'session_id'}>\n|;
- print qq|<input type="hidden" name="version" value=$fld{'version'}>\n|;
- print qq|<input type="hidden" name="my_ip" value=$fld{'my_ip'}>\n|;
- print qq|<input type="hidden" name="username" value=$fld{'username'}>\n|;
- print qq|<input type="hidden" name="edit_file" value=$val{'edit_file'}>\n|;
- }
-
- print qq|<input type="hidden" name="feb_days" value="$feb_days">\n|;
-
- print qq|<table width=600>\n|;
-
- print qq|<tr><th align=left>Session Name:</th><td align=left>\n|,
- &mtext("session_name", $val{'session_name'}, 30), "</td></tr>\n";
-
- print qq|<tr><th align=left valign=top>Description:</th><td align=left>\n|,
- qq|<textarea name="description" rows=5 cols=40>$val{'description'}|,
- qq|</textarea></td></tr>|;
-
- print qq|<tr><th align=left>URI:</th><td align=left>\n|,
- &text("uri", $val{'uri'}, 30), "</td></tr>\n";
-
- print qq|<tr align=left><th>Address:</th><td align=left>\n|,
- &text("address", $val{'address'}, 30), "</td></tr>\n";
-
- print qq|<tr><th align=left>Scope (ttl):</th><td align=left>\n|,
- &select("ttl",$val{'ttl'},"site","region","world"), "</td></tr>\n";
-
- print qq|</table><hr><table width=600>\n|;
-
- print qq|<tr><th align=left colspan=2>Media</th><th align=left>Recvonly</th>|,
- qq|<th align=left>Protocol</th><th align=left>Format</th><th align=left>|,
- qq|Port</th></tr>\n|;
-
- print qq|<tr><td>|, &check("audio_check", $val{'audio_check'}),
- qq|</td><th align=left>Audio</th>|;
- print qq|<td>|, &check("audio_recv", $val{'audio_recv'}), qq|</td>|;
- print qq|<td>|, &select("audio_protocol", $val{'audio_protocol'},"vat","rtp"),
- qq|</td>\n|;
- print qq|<td>|, &select("audio_format", $val{'audio_format'},"pcm","dvi","gsm","lpc4"),
- qq|</td>\n|;
- print qq|<td>|, &text("audio_port", $val{'audio_port'}, 6), qq|</td>\n|;
- print qq|</tr>|;
-
- print qq|<tr><td>|, &check("video_check", $val{'video_check'}),
- qq|</td><th align=left>Video</th>|;
- print qq|<td>|, &check("video_recv", $val{'video_recv'}), qq|</td>|;
- print qq|<td>|, &select("video_protocol", $val{'video_protocol'},"rtp"), qq|</td>\n|;
- print qq|<td>|, &select("video_format", $val{'video_format'},"nv","h261","jpg","ivs"),
- qq|</td>\n|;
- print qq|<td>|, &text("video_port", $val{'video_port'}, 6), qq|</td>\n|;
- print qq|</tr>|;
-
- print qq|<tr><td>|, &check("white_check", $val{'white_check'}),
- qq|</td><th align=left>Whiteboard</th>|;
- print qq|<td>|, &check("white_recv", $val{'white_recv'}), qq|</td>|;
- print qq|<td>|, &select("white_protocol", $val{'white_protocol'},"udp"), qq|</td>\n|;
- print qq|<td>|, &select("white_format", $val{'white_format'},"wb","nt"), qq|</td>\n|;
- print qq|<td>|, &text("white_port", $val{'white_port'}, 6), qq|</td>\n|;
- print qq|</tr>|;
-
- print qq|<tr><td>|, &check("text_check", $val{'text_check'}), qq|</td><th align=left>Text</th>|;
- print qq|<td>|, &check("text_recv", $val{'text_recv'}), qq|</td>|;
- print qq|<td>|, &select("text_protocol", $val{'text_protocol'},"udp"), qq|</td>\n|;
- print qq|<td>|, &select("text_format", $val{'text_format'},"nt","mumble"), qq|</td>\n|;
- print qq|<td>|, &text("text_port", $val{'text_port'}, 6), qq|</td>\n|;
- print qq|</tr>|;
-
- print qq|</table><hr><table width=600>|;
-
- print qq|<tr><th align=left>Broadcast</th><td align=left>\n|;
- print &select("active",$val{'active'},"once","daily","weekly"), "</td></tr>\n";
- print "<tr><th align=left>From:</th><td align=left>",
- qq|<input type="text" name="date" value="$val{'date'}" size=10 onFocus="this.blur();">\n|,
- qq|<img src="/images/arrows.gif" border=2 align="top" usemap="#date_map">\n|,
- qq|<input type="text" name="time" value="$val{'time'}" size=5 onFocus="this.blur();">\n|,
- qq|<img src="/images/arrows.gif" border=2 align="top" usemap="#time_map">\n|,
- qq| for |,
- &select("duration",$val{'duration'},"30 minutes","1 hour","2 hours","3 hours",
- "4 hours","5 hours","6 hours","7 hours","8 hours","9 hours",
- "10 hours","1 day"), "</td></tr>\n";
- print qq|<tr><th align=left>Repeat for:</th><td align=left>\n|,
- &select("repeat",$val{'repeat'},"1 hour","2 hours","3 hours","4 hours",
- "5 hours","6 hours","7 hours","8 hours","9 hours","10 hours",
- "1 day","2 days","3 days","4 days","5 days","1 week","2 weeks",
- "3 weeks","4 weeks"),
- qq|</td></tr>\n|;
-
- print qq|</table><hr><table width=600>\n|;
-
- print qq|<tr><th align=left>email:</th><td>|,
- qq|<input type=text name="email" value="$val{'email'}" size=30></td></tr>\n|;
-
- print qq|<tr><th align=left>phone:</th><td>|,
- qq|<input type=text name="phone" value="$val{'phone'}" size=30></td></tr>\n|;
-
- print qq|</table><table width=600>\n|;
-
- print qq|<tr><td><input name="submit" type="submit" value="Submit Announcement"></td></tr>\n|;
-
- print qq|</table>\n|;
-
- print qq|</center></form></body></html>\n|;
-
- }
-
- sub mtext {
- local($ret) = "<input name=\"$_[0]\" value=\"$_[1]\"";
- if ($_[2]) { $ret .= " size=$_[2]"; }
- $ret .= ">";
- }
-
- sub check {
- local($ret) = qq|<input type=checkbox name=$_[0]|;
- if ($_[1]) { $ret .= " checked"; }
- $ret .= ">";
- }
-
- sub print_javascript {
-
- print <<EOJS
-
- <script language="JavaScript">
- <!--
-
- function TimeUp()
- {
- var hours, minutes;
- form = document.page1;
- hours = form.time.value.substring(0,2);
- minutes = form.time.value.substring(3,5);
- if (minutes == "30") {
- hours = eval(hours + "+1");
- if (hours < 10) { hours = "0" + hours; }
- if (hours > 23) { hours = "00"; }
- minutes = "00";
- } else {
- minutes = "30";
- }
- form.time.value = hours + ":" + minutes;
- }
-
- function TimeDown()
- {
- var hours, minutes;
- form = document.page1;
- hours = form.time.value.substring(0,2);
- minutes = form.time.value.substring(3,5);
- if (minutes == "30") {
- minutes = "00";
- } else {
- hours = eval(hours + "-1");
- if (hours < 0) { hours = "23"; }
- if (hours < 10) { hours = "0" + hours; }
- minutes = "30";
- }
- form.time.value = hours + ":" + minutes;
- }
-
- function DateUp()
- {
- days_in_month = new createArray(12);
- days_of_week = new createArray(7);
- mon_yr = new createArray(12);
- var j, week_day, week_day_nm, num_day, month;
- var add_month;
-
- form = document.page1;
-
- mon_yr[0] = "Jan"; mon_yr[1] = "Feb"; mon_yr[2] = "Mar"; mon_yr[3] = "Apr";
- mon_yr[4] = "May"; mon_yr[5] = "Jun"; mon_yr[6] = "Jul"; mon_yr[7] = "Aug";
- mon_yr[8] = "Sep"; mon_yr[9] = "Oct"; mon_yr[10] = "Nov"; mon_yr[11] = "Dec";
-
- for (j=0; j<12; j++) { days_in_month[j] = 31; }
- days_in_month[1] = form.feb_days.value;
- days_in_month[3] = 30;
- days_in_month[5] = 30;
- days_in_month[8] = 30;
- days_in_month[10] = 30;
-
- days_of_week[0] = "Sun"; days_of_week[1] = "Mon"; days_of_week[2] = "Tue"; days_of_week[3] = "Wed";
- days_of_week[4] = "Thu"; days_of_week[5] = "Fri"; days_of_week[6] = "Sat";
-
- week_day = form.date.value.substring(0,3);
- num_day = form.date.value.substring(8,10);
- month = form.date.value.substring(4,7);
-
- for (j=0; j<7; j++) {
- if (week_day == days_of_week[j]) { week_day_nm = j; }
- }
- week_day_nm = eval(week_day_nm + "+1");
- if (week_day_nm > 6) { week_day = "Sun"; }
- else { week_day = days_of_week[week_day_nm]; }
-
- for (j=0; j<12; j++) {
- if (month == mon_yr[j]) { month_nm = j; }
- }
- add_month = 0;
- if (num_day == days_in_month[month_nm]) {
- num_day = 1;
- add_month = 1;
- } else { num_day = eval(num_day + "+1"); }
- if (add_month == 1) {
- month_nm = eval(month_nm + "+1");
- if (month_nm == 12) { month_nm = 1; }
- month = mon_yr[month_nm];
- }
-
- form.date.value = week_day + " " + month + " " + num_day;
- }
-
- function DateDown()
- {
- days_in_month = new createArray(12);
- days_of_week = new createArray(7);
- mon_yr = new createArray(12);
- var j, week_day, week_day_nm, num_day, month;
-
- form = document.page1;
- mon_yr[0] = "Jan"; mon_yr[1] = "Feb"; mon_yr[2] = "Mar"; mon_yr[3] = "Apr";
- mon_yr[4] = "May"; mon_yr[5] = "Jun"; mon_yr[6] = "Jul"; mon_yr[7] = "Aug";
- mon_yr[8] = "Sep"; mon_yr[9] = "Oct"; mon_yr[10] = "Nov"; mon_yr[11] = "Dec";
-
- for (j=0; j<12; j++) { days_in_month[j] = 31; }
- days_in_month[1] = form.feb_days.value;
- days_in_month[3] = 30;
- days_in_month[5] = 30;
- days_in_month[8] = 30;
- days_in_month[10] = 30;
-
- days_of_week[0] = "Sun"; days_of_week[1] = "Mon"; days_of_week[2] = "Tue"; days_of_week[3] = "Wed";
- days_of_week[4] = "Thu"; days_of_week[5] = "Fri"; days_of_week[6] = "Sat";
-
- week_day = form.date.value.substring(0,3);
- num_day = form.date.value.substring(8,10);
- month = form.date.value.substring(4,7);
- for (j=0; j<7; j++) {
- if (week_day == days_of_week[j]) { week_day_nm = j; }
- }
-
- week_day_nm = eval(week_day_nm + "-1");
- if (week_day_nm < 0) { week_day = "Sat"; }
- else { week_day = days_of_week[week_day_nm]; }
- for (j=0; j<12; j++) {
- if (month == mon_yr[j]) { month_nm = j; }
- }
-
- num_day = eval(num_day + "-1");
- if (num_day < 1) {
- month_nm = eval(month_nm + "-1");
- if (month_nm < 0) { month_nm = 11; }
- num_day = days_in_month[month_nm];
- month = mon_yr[month_nm];
- }
-
- form.date.value = week_day + " " + month + " " + num_day;
- }
-
- function createArray(num) {
- this.length = 12;
- for (var j=0; j < num; j++) { this[j] = ""; }
- }
-
-
- // -->
- </script>
-
- EOJS
-
- }
-